package hr.dao.impl;

import hr.dao.EmployeeDao;
import hr.models.Employee;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: VMoskalenko
 * Date: 25.06.12
 * Time: 22:58
 */
public class EmployeeDaoImpl implements EmployeeDao {

    @PersistenceContext
    EntityManager em;

    @Override
    public List<Employee> all() {
        return em.createQuery("select e from Employee e", Employee.class).getResultList();
    }

    @Override
    public void delete(String rising) {

    }


    @Override
    public Employee findByName(String firstName, String lastName) {
        return em.createQuery("select e from Employee e where firstName=:firstName and lastName=:lastName", Employee.class)
                .setParameter("firstName", firstName)
                .setParameter("lastName", lastName)
                .getSingleResult();
    }
}
